WSL+Systemd+Gnome+VcXsrv+CUDAToolkit 安装 |
您所在的位置:网站首页 › ubuntu2004 自启动 › WSL+Systemd+Gnome+VcXsrv+CUDAToolkit 安装 |
我的版本信息
wsl: PS C:\Users\kirk> wsl --update 正在检查更新... 无更新使用。 内核版本: 5.10.102.1Ubuntu: kirk@KirkComputer:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.4 LTS Release: 20.04 Codename: focal 安装UbuntuWSL安装建议参照参照官方文档,我就不介绍了,安装的是默认的Ubuntu,我看了下目前版本是Ubuntu-20.04和选择安装Ubuntu-20.04是一样的安装 WSL | Microsoft Docs 网上的DamionGans/ubuntu-wsl2-systemd-script我这个版本好像已经不能用了,所以我参考的是github上的GitHub - nullpo-head/wsl-distrod: Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability.Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability. - GitHub - nullpo-head/wsl-distrod: Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability. 下面是WSL 安装systemd的脚本,实测好像不用加 --start-on-windows-boot 跟随系统启动也不影响 #这个install.sh 网络问题,可以开vpn 下载来再拷过去 #内容第五行:LATEST_RELEASE_URL="https://github.com/nullpo-head/wsl-distrod/releases/latest/download/opt_distrod.tar.gz" #默认下载最新的包 进行安装 curl -L -O "https://raw.githubusercontent.com/nullpo-head/wsl-distrod/main/install.sh" chmod +x install.sh sudo ./install.sh install #安装成功 执行 sudo /opt/distrod/bin/distrod enable --start-on-windows-boot #--------------------------显示内容------------------------------------- # [Distrod] Distrod has been enabled. Now your shell will start under systemd. # [Distrod] Enabling atuomatic startup of Distrod. UAC dialog will appear because scheduling # a task requires the admin privilege. Please hit enter to proceed. #--------------------------显示内容------------------------------------- #这里提示你要回车,回车之后,会弹出管理员授权点同意,然后会让你输入密码(注:windows的用户密码)要创建任务计划程序,密码输错了,就继续重试 内容如下: #--------------------------显示内容------------------------------------- # Error # It seems the task has not been scheduled successfully. You may have typed a wrong password, or you may not have the # necessary administrative privileges. Do you want to retry? # [Y] Yes [N] No [?] 帮助 (默认值为“Y”): #--------------------------显示内容------------------------------------- #如果密码输入正确,并且成功创建任务计划程序会显示下面内容: #--------------------------显示内容------------------------------------- # Enabling autostart has succeeded. # [Distrod] Distrod will now start automatically on Windows startup. #--------------------------显示内容------------------------------------- #补充: 如果加 --start-on-windows-boot 执行失败的话 报错信息是 Caused by: C drive not found. # 在容器外部为 Systemd 打开一个 Shell 会话 ,打开powershell 输入 wsl -d Ubuntu -e /bin/bash # 再重复 sudo /opt/distrod/bin/distrod enable --start-on-windows-boot 操作 #到此就结束了安装成功 #查看版本 distrod --version # distrod 0.1.4 #测试 systemctl status # ● KirkComputer # State: running # Jobs: 0 queued # Failed: 0 units # Since: Mon 2022-05-09 23:15:56 +08; 22min ago # CGroup: /上述 install.sh 我就贴在这里省得翻墙,要最新的话还是参照上面地址去获取,内容如下: #!/bin/sh set -e #这里默认获取的是最新的安装包,可以自己修改想要的版本 LATEST_RELEASE_URL="https://github.com/nullpo-head/wsl-distrod/releases/latest/download/opt_distrod.tar.gz" HELP_STR="Usage: $0 command: - install - update - uninstall" help () { echo "$HELP_STR" } error_help () { error "$HELP_STR" } install () { mkdir /opt/distrod || error "Failed to create /opt/distrod." cd /opt/distrod || error "Could not change directory to /opt/distrod" get_release_file tar xvf opt_distrod.tar.gz rm opt_distrod.tar.gz echo "Installation is complete!" } uninstall () { if grep -o systemd /proc/1/status > /dev/null; then error "This uninstall command cannot run inside a running Distrod distro." error "To uninstall it, do the following first." error "1. /opt/distrod/bin/distrod disable # Stop systemd from starting as init" error "2. wsl.exe --shutdown # Terminate WSL2" error "After that, Systemd will not run as the init and you can run uninstall." exit 1 fi rm -rf /opt/distrod echo "Distrod has been uninstalled!" } update () { cd /opt/distrod || error "Could not change directory to /opt/distrod" get_release_file EXCLUDE="" for FILE in /opt/distrod/conf/*; do FILE=${FILE#/opt/distrod/} if printf "%s" "$FILE" | grep -E ' '; then error "Found a file with a name containing spaces. Please remove it. Aborting update command." exit 1 fi EXCLUDE="$EXCLUDE --exclude $FILE" done # shellcheck disable=SC2086 tar xvf opt_distrod.tar.gz $EXCLUDE echo "Ruuning post-update actions..." POST_UPDATE="/opt/distrod/misc/distrod-post-update" if [ -e "${POST_UPDATE}" ]; then "${POST_UPDATE}" fi echo "Distrod has been updated!" } get_release_file() { if [ -n "$RELEASE_FILE" ]; then cp "$RELEASE_FILE" opt_distrod.tar.gz else curl -L -O "${LATEST_RELEASE_URL}" fi } error () { echo "$@" >&2 } if [ -z "$1" ]; then error_help exit 1 fi if [ "$(whoami)" != "root" ]; then error "You must be root to run this script, please use sudo ./install.sh" exit 1 fi COMMAND= while [ -n "$1" ]; do case "$1" in -h|--help) echo "$HELP_STR" exit 0 ;; install) COMMAND=install shift ;; uninstall) COMMAND=uninstall shift ;; update) COMMAND=update shift ;; -r|--release-file) RELEASE_FILE="$(realpath "$2")" shift 2 ;; -*) error "Error: Unknown flag $1" exit 1 ;; *) # preserve positional arguments error "Error: Unknown command $1" exit 1 ;; esac done "$COMMAND" 安装Gnome这个我参考了底部链接那个老哥的链接,目前只有root能用,普通用户没法使用,我后面再研究研究 1:windows 安装VcXsrv 这个自行安装,下载地址: VcXsrv Windows X Server download | SourceForge.net 3:windows 打开 VcXsrv #参数基本默认,只需要改动三处:进入之后选择one large window;display number设为0;下一步,下一步,勾上disable access control,可以保存配置,也可以不保存 4:WSL 执行 sudo gnome-session sudo gnome-session #此时 VcXsrv中已经显示了ubuntu界面到这里图形界面就安装成功了,中文包还有Gnome其他组件看个人需求自己加。 安装CUDAToolkit这个可安装可不安装,主要用来GPU加速,没有显卡就不管了,用不到GPU运算也不用管了 windows要安装CPU驱动和GPU驱动这个对应自己的笔记本版本号可以参考官方文档 WSL 中的 GPU 加速 ML 训练 | Microsoft Docs CUDA on WSL :: CUDA Toolkit Documentation (nvidia.com) 参考链接有 (66条消息) Windows中WSL2 配置运行GNOME桌面版 Ubuntu_Hack电子的博客-CSDN博客 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |